package com.baidu.inetAdress;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;

public class InetAdressDemo {
    public static void main(String[] args) throws Exception {
        InetAddress localHost = InetAddress.getLocalHost();
        System.out.println(localHost.getHostName());
        System.out.println(localHost.getHostAddress());

        InetAddress byName = InetAddress.getByName("www.baidu.com");
        System.out.println(byName.getHostName());
        System.out.println(byName.getHostAddress());

        InetAddress byAddress = InetAddress.getByName("110.242.68.4");
        System.out.println(byAddress.getHostName());
        System.out.println(byAddress.getHostAddress());

    }
}
